<?php

require_once 'Zend/Validate/Abstract.php';

class Kzend_Validate_Numeric extends Zend_Validate_Abstract
{

    const NOT_CORRECT = 'notCorrect';

    protected $_labelName = '';

    protected $_messageTemplates = array(
            self::NOT_CORRECT => '%labelName% must be an alphanumeric value.',);

    protected $_messageVariables = array(
            'labelName' => '_labelName',);

    public function __construct($labelName)
    {
        $this->_labelName = $labelName;
    }

    public function isValid($value)
    {
        $valueString = (string) $value;
        $this->_setValue($valueString);

        if ('' === $valueString || preg_match('/[^a-zA-Z0-9]/', $valueString) > 0) {
            $this->_error(self::NOT_ALNUM);
            return false;
        }

        return true;
    }
}

